<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <LINK rel="Bookmark" href="/favicon.ico" >
    <LINK rel="Shortcut Icon" href="/favicon.ico" />
    <link rel="stylesheet" type="text/css" href="/static/admin/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="/static/admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="/static/admin/css/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="/static/admin/css/style.css" />
    <title>商品列表</title>
</head>
<body>
<div class="page-container">
    <div class="mt-20">
        <table class="table table-border table-bordered table-hover table-bg table-sort mt-10">
            <thead>
            <tr class="text-c">
                <th width="40">商品ID</th>
                <th width="150">商品名称</th>
                <th width="70">数量</th>
                <th width="100">操作</th>
            </tr>
            </thead>
            <tbody>
            <?php foreach($list as $v):?>
            <tr class="text-c">
                <td><?php echo $v['gid']?></td>
                <td><?php echo $v['name'];?></td>
                <td><input type="text" class="input-text" style="text-align: center" value="<?php echo $v['qty'];?>" onblur="qty(this,'<?php echo $v['id']?>')"></td>
                <td class="td-manage">
                    <a class="ml-5" href="javascript:;" title="删除动态"  onclick="del(this,'<?php echo $v['id']?>')" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
                </td>
            </tr>
            <?php endforeach;?>
            </tbody>
        </table>
    </div>
    <span class="r pages mt-10"><?php echo $page?></span>
</div>
<script type="text/javascript" src="/static/admin/js/jquery.min.js"></script>
<script type="text/javascript" src="/static/admin/js/layer.js"></script>
<script type="text/javascript" src="/static/admin/js/H-ui.min.js"></script>
<script type="text/javascript" src="/static/admin/js/H-ui.admin.js"></script>
<script type="text/javascript">
/*修改数量*/
function qty(obj,id){
    var qty = $(obj).val();
    $.ajax({
        type:'post',
        url:"<?php echo url('goods/comboQty')?>",
        data:{"id":id,"qty":qty},
        success:function(data){
            if(typeof data === 'string'){
                data = jQuery.parseJSON(data);
            }
            if(data.code == 0){
                layer.msg(data.msg,{icon:1,time:1000});
            }else{
                layer.msg(data.msg,{icon:5,time:1000});
            }
        }
    });
}

/*删除*/
function del(obj,id){
    layer.confirm('删除须谨慎，确认要删除吗？',function(index){
        $.ajax({
            type:'post',
            url:"<?php echo url('goods/comboDel')?>",
            data:{"id":id},
            success:function(data){
                if(typeof data === 'string'){
                    data = jQuery.parseJSON(data);
                }
                if(data.code == 0){
                    $(obj).parents("tr").remove();
                    layer.msg(data.msg,{icon:1,time:1000});
                }else{
                    layer.msg(data.msg,{icon:5,time:1000});
                }
            }
        });
    });
}

/*详情*/
function show(title,url,id,w,h){
    layer_show(title,url,w,h);
}
</script>
</body>
</html>